<template>
	<view class="flex-col page">
		<view class="flex-col flex-auto section_3">
			<text class="self-start text_4">{{content.subject}}</text>
			<text class="self-start text_5">{{content.create_time}}</text>
			<view class="flex-col group space-y-28">
				<view class="font_2" v-html="content.content"></view>
			</view>
			<view class="flex-row items-center  text_5" v-if="content.target_rule!=0" @click="toTarget"> 了解详情>></view>
		</view>
	</view>
</template>

<script setup>
	import {
		onShow,
		onLoad
	} from "@dcloudio/uni-app";
	import {
		onMounted,
		ref,
		reactive,
		getCurrentInstance
	} from "vue"
	const {
		proxy
	} = getCurrentInstance()
	onLoad((option) => {
		console.log(option);
		msg_id.value = option.msg_id
		getDate()

	})
	let msg_id = ref('')
	let content = ref({})

	const getDate = () => {
		proxy.$req.requestPOST(proxy.$api.CenterInfo.messageDetail, {
			member_id: uni.getStorageSync('member_id'),
			msg_id: msg_id.value
		}).then(res => {
			content.value = res.data
		})
		proxy.$req.requestPOST(proxy.$api.CenterInfo.setRead, {
			member_id: uni.getStorageSync('member_id'),
			msg_id: msg_id.value
		}).then(res => {
			console.log(res, '已读');
		})
	}
	const toTarget = () => {
		console.log(content.value.target_rule);
		switch (content.value.target_rule) {
			case '1':
				//网址
				uni.navigateTo({
					url: "/pages/webHttp/webHttp?url=" + JSON.stringify(content.value.param)
				})
				break;
			case '2':
				//新品
				uni.navigateTo({
					url: "/pages/news/news"
				})
				break;
			case '3':
				//限时抢购
				uni.navigateTo({
					url: "/pages/flash/flash"
				})
				break;
			case '4':
				//团购列表
				uni.navigateTo({
					url: "/pages/groupBuying/groupBuying?parm="+content.value.param
				})
				break;
			case '5':
				//活动详情
				uni.navigateTo({
					url: '/pages/buyingDetail/buyingDetail?type=1&active_id=' + content.value.param
				})
				break;
			case '6':
				//签到
				uni.navigateTo({
					url: "/pages/sign/sign"
				})
				break;
			default:
				break;
		}
	}
</script>

<style scoped lang="css">
	.page {
		background-color: #ffffff;
		width: 100%;
		overflow-y: auto;
		overflow-x: hidden;
		height: 100%;
	}

	.section_3 {
		padding: 44rpx 29rpx 1005rpx;
		background-color: #ffffff;
		overflow-y: auto;
	}

	.text_4 {
		color: #333333;
		font-size: 30rpx;
		font-family: PingFangSC;
		line-height: 29rpx;
	}

	.text_5 {
		margin-left: 3rpx;
		margin-top: 25rpx;
		color: #86888c;
		font-size: 22rpx;
		font-family: PingFangSC;
		line-height: 17rpx;
	}

	.group {
		margin-top: 36rpx;
	}

	.space-y-28>view:not(:first-child),
	.space-y-28>text:not(:first-child),
	.space-y-28>image:not(:first-child) {
		margin-top: 28rpx;
	}

	.font_2 {
		font-size: 26rpx;
		font-family: PingFangSC;
		line-height: 44rpx;
		color: #aeb0bc;
	}
</style>